<script>
import Common from "@/mixins/order/commonbg.js";
import OrderService from "@/api/order/OrderService.js";
import PPMForm from "@/crm3.0part7-ppm/core/ppmForm.vue";
export default {
  name: "mstp10461030",
  mixins: [PPMForm, Common],
  data() {
    return {
      //MSTP	正常变更	帐务变更
      // proName: 'MSTP'
      APort: false, //是否是A端业务
      oldEndDate: "", //原单的合同终止日期
    };
  },
  async mounted() {
    let OldOrderInfo = await this.initCommon();
    // // 
    let ordProdInstsAttrs = OldOrderInfo.ordProdInstsAttrs;
    ordProdInstsAttrs.forEach((item) => {
      if (item.attrId == "100013370" && item.attrValue == "98000001") {
        //A端业务
        this.APort = true;
      }
      if (item.attrId == "142002037") {
        if (item.attrValue) {
          this.oldEndDate = item.attrValue;
        }
      }
    });
    var orgId = this.user.orgId;
    if (orgId == "1944640") {
      this.formData["10461186-141000248"].isshow = true; //是否上传特批附件 显示
    } else {
      this.formData["10461186-141000248"].isshow = false; //是否上传特批附件 隐藏
    }
  },

  computed: {},
  methods: {
    //A端向客户收取境外侧金额改变
    outMoney() {
      if (this.APort) {
        if (this.formData["10461195-100012713"].value != "") {
          this.$confirm(
            "【向客户收取境外侧金额】已做变更，系统自动默认币种为人民币!",
            "提示",
            {
              confirmButtonText: "确定",
              cancelButtonText: "取消",
              type: "warning",
            }
          )
            .then(() => {
              this.formData["10461195-100013341"].value =
                this.formData["10461195-100012713"].value; //国际对端结算金额
              this.formData["10461195-100012721"].value = "156"; //向客户收取境外侧金额币种
              this.formData["10461195-100012606"].value = "1"; //收付一致标志
              this.formData["10461195-100012773"].value = "156"; //国际对端结算金额币种
            })
            .catch(() => {
              this.formData["10461195-100012713"].value = "";
              this.formData["10461195-100013341"].value = ""; //国际对端结算金额
              this.formData["10461195-100012721"].value = ""; //向客户收取境外侧金额币种
              this.formData["10461195-100012606"].value = ""; //收付一致标志
              this.formData["10461195-100012773"].value = ""; //国际对端结算金额币种
            });
        }
      }
    },
    //终止合同日期改变
    dateVal() {
      let newEndDate = this.formData["10461186-142002037"].value;
      if (this.oldEndDate) {
        if (
          new Date(newEndDate).getTime() < new Date(this.oldEndDate).getTime()
        ) {
          this.$alert("合同终止日期要大于原单的合同终止日期", "提示", {
            type: "warning",
          });
          this.formData["10461186-142002037"].value = "";
        }
      }
    },
    getPluginValue(obj) {
      if (obj.key == "10461185-100013695") {
        let user = JSON.parse(sessionStorage.getItem("crm3-userinfo"));
        if (user.orgId != "1944640" && obj.data.orgId == "1944640") {
          this.$confirm("省客户不能选择集团公司为收款单位!", "提示", {
            confirmButtonText: "关闭",
            showCancelButton: false,
            type: "warning",
            center: true,
          });
        } else {
          this.formData["10461200-100011992"].text = obj.data.accountUnitName;
          this.formData["10461200-100011992"].value = obj.data.accountUnitCode;
          this.formData["10461201-100011992"].text = obj.data.accountUnitName;
          this.formData["10461201-100011992"].value = obj.data.accountUnitCode;
          this.formData["10461202-100012758"].text = obj.data.accountUnitName;
          this.formData["10461202-100012758"].value = obj.data.accountUnitCode;
          this.formData["10461203-100012795"].text = obj.data.accountUnitName;
          this.formData["10461203-100012795"].value = obj.data.accountUnitCode;
          this.formData["10461205-100010007"].text = obj.data.accountUnitName;
          this.formData["10461205-100010007"].value = obj.data.accountUnitCode;
          this.formData["10461206-100010007"].text = obj.data.accountUnitName;
          this.formData["10461206-100010007"].value = obj.data.accountUnitCode;
        }
      }else if (obj.key == "10461185-142003017") {
        this.formData["10461200-100012144"].text = obj.data.accountUnitName;
        this.formData["10461200-100012144"].value = obj.data.accountUnitCode;
        this.formData["10461201-100012144"].text = obj.data.accountUnitName;
        this.formData["10461201-100012144"].value = obj.data.accountUnitCode;
        this.formData["10461202-100012823"].text = obj.data.accountUnitName;
        this.formData["10461202-100012823"].value = obj.data.accountUnitCode;
        this.formData["10461203-100012836"].text = obj.data.accountUnitName;
        this.formData["10461203-100012836"].value = obj.data.accountUnitCode;
        this.formData["10461205-100010008"].text = obj.data.accountUnitName;
        this.formData["10461205-100010008"].value = obj.data.accountUnitCode;
        this.formData["10461206-100010008"].text = obj.data.accountUnitName;
        this.formData["10461206-100010008"].value = obj.data.accountUnitCode;
      }
    },
    getInputGridValue(obj) {
      if (obj.key == "10461200-100011992") {
        this.judgeID(obj.key, obj.data);
      } else if (obj.key == "10461201-100011992") {
        this.judgeID(obj.key, obj.data);
      } else if (obj.key == "10461202-100012758") {
        this.judgeID(obj.key, obj.data);
      } else if (obj.key == "10461203-100012795") {
        this.judgeID(obj.key, obj.data);
      } else if (obj.key == "10461205-100010007") {
        this.judgeID(obj.key, obj.data);
      } else if (obj.key == "10461206-100010007") {
        this.judgeID(obj.key, obj.data);
      }
    },
    judgeID(key, value) {
      let user = JSON.parse(sessionStorage.getItem("crm3-userinfo"));
      if (user.orgId != "1944640" && value.orgId == "1944640") {
        this.formData[key].text = "";
        this.formData[key].value = "";
        this.$confirm("省客户不能选择集团公司为收款单位!", "提示", {
          confirmButtonText: "关闭",
          showCancelButton: false,
          type: "warning",
          center: true,
        });
      } else {
        this.formData[key].text = value.accountUnitName;
        this.formData[key].value = value.accountUnitCode;
      }
    },
    isModContactLimit() {
      if(this.formData["10461186-142000765"].value=='1'){
        this.SetRequired({ attrName:'合同终止日期', formkey:'10461186-142002037', reqName:'empty', reqStatus:true});
      }else{
        this.SetRequired({ attrName:'合同终止日期', formkey:'10461186-142002037', reqName:'empty', reqStatus:false});
      }
    },

  },
};
</script>